<div id="templatemo_upcomming_event" class="container_wapper">
    <div class="container">
        <h1 align="center" style="font-family: calibri; margin-bottom: 20px;"> -------------------Tambah Kontak-------------------</h1>        
        <table id="table-content">                
            <tr>
                <td align="left">Nama Kontak</td>
                <td>:</td>                                            
                <td><input type="text" id="nama_kontak" value=""/></td> 
            </tr>
            <tr>
                <td align="left">No. HP</td>
                <td>:</td>                                            
                <td><input type="text" id="notelp_kontak" value="<?= $notelp_pemilik; ?>"/></td> 
            </tr>
            <tr>
                <td align="left">Group</td>
                <td>:</td>                                            
                <td><input type="text" id="group" value=""/></td> 
            </tr>
            <tr>
                <td align="left">Keterangan</td>
                <td>:</td>                                            
                <td><input type="text" id="keterangan" value=""/></td> 
            </tr>
            <tr>
                <td></td>
                <td></td>
                <td><input type="button" id="update_profil" name="update_profil" class="button_blue" value="Update"></td>
            </tr>
        </table>
    </div>
</div>
<script>
    $(function() {
        $("#update_profil").click(function(event) {
    var nama_kontak = document.getElementById('nama_kontak').value;
            var notelp_kontak = document.getElementById('notelp_kontak').value;
            var group = document.getElementById('group').value;
            var keterangan = document.getElementById('keterangan').value;

            if (nama_kontak == "" || notelp_kontak == "") {
            show_alert("Nama atau No. HP tidak boleh kosong");
            } else {
                show_dialog("Silahkan tunggu, transaksi anda sedang kami proses...");
                $.ajax({
            url: '<?php echo base_url(); ?>index.php/pesan/kontak_insert',
                            type: "POST",
                                timeout: 30000,
                    data: {
                                nama_kontak: nama_kontak,
                                notelp_kontak: notelp_kontak,
                                    group: group,
                                    keterangan: keterangan,
                        '<?php echo $this->security->get_csrf_token_name(); ?>': '<?php echo $this->security->get_csrf_hash(); ?>'
                                                },
                    success: function(result)
                    {
                                            var obres = $.parseJSON(result);
                                            var err_code = obres.err_code;

                                                if (err_code !== "00") {
                                                hide_dialog(obres.msg);
                        }
                                                else
                        {
                                                    hide_dialog("");
                                                alert(obres.msg);
                                                location.href = "<?= site_url("/pesan/pesan_masuk/") ?>";
                                                                            }
                    },
                                                                            error: function()
                    {
                                                                    hide_dialog("Terdapat masalah dengan koneksi internet anda, silahkan coba kembali.");
                                                                    }
                                                                        });
            }
        });
    });
</script>
</body>
</html>